#include<bits/stdc++.h>
using namespace std;
#define A 100005
#define ll long long
ll b[10000],c[10000];
struct car{
    int di,vi,ai;
    int d[10000];
}a[10000];

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int n,m,l,v,t;
    cin>>t;
    while(t!=0){
        int k=0,z=0;
        scanf("%ld%ld%ld%ld",&n,&m,&l,&v);
        for(int i=1;i<=n;i++){
            scanf("%d%d%d",&a[i].di,&a[i].vi,&a[i].ai);
        }
        for(int i=1;i<=m;i++){
            cin>>b[i];
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<m;j++){
                if(b[j]>a[i].di){
                    a[i].d[j]=sqrt(pow(a[i].vi,2)+2*a[i].ai*(b[j]-a[i].di));
                    if(a[i].d[j]>=v){
                        k++;
                        c[j]++;
                        break;
                    }
                }
            }
        }
        cout<<k<<" ";
        for(int i=1;i<=m;i++){
            if(c[i]!=0) z++;
        }
        cout<<m-z;
        t--;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
